/*
 * linearinterpolation.c
 *
 */

#include <linear_interpolation.h>

inline int32_t linear_interpolation(fx_t fraction, int32_t v1, int32_t v2) {
	/* Linear interpolation
	 * v1 = current sample
	 * v2 = current sample + 1
	 */
	//return v1 + ((v2 - v1) * fraction);

	fx_t q1 = fx_make(v1);
	fx_t q2 = fx_make(v2);
	fx_t temp1 = q2 - q1;
	fx_t temp2 = fx_mul( temp1, fraction);
	fx_t temp3 = q1 + temp2;
	return fx_trunc_to_int32( temp3 );
}
